'use strict';
// 微信登录 用户表
module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, ENUM } = Sequelize;
    // 创建表
    await queryInterface.createTable('wx_user', {
      id: {
        type: INTEGER(20).UNSIGNED,
        primaryKey: true,
        autoIncrement: true
      },
      nickname: {
        type: STRING(20),
        allowNull: false,
        defaultValue: '',
        comment: '昵称',
      },
      avatar: {
        type: STRING(200),
        allowNull: false,
        defaultValue: '',
        comment: '头像',
      },
      openid: {
        type: STRING(100),
        allowNull: false,
        defaultValue: '',
        comment: '用户唯一标识',
      },
      session_key: {
        type: STRING(100),
        allowNull: false,
        defaultValue: '',
        comment: '微信 session_key',
      },
      token: {
        type: STRING(6000),
        allowNull: false,
        defaultValue: '',
        comment: 'token',
      },
      role: {
        type: ENUM,
        values: ['agent', 'user'],
        allowNull: false,
        defaultValue: 'user',
        comment: '角色  agent代理  user用户'
      },
      withdrawal_price: {
        type: INTEGER(30),
        allowNull: false,
        defaultValue: '0',
        comment: '可提现金额',
      },
      total_price: {
        type: INTEGER(30),
        allowNull: false,
        defaultValue: '0',
        comment: '总收益',
      },
      status: {
        type: ENUM,
        values: ['0', '1',],
        allowNull: false,
        defaultValue: '1',
        comment: '状态 0禁用 1启用 '
      },
      created_at: DATE,
      updated_at: DATE,
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('wx_user');
  }
};
